<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="UTF-8">
	<title></title>
	<script th:src="@{/layui/layui.js}" type="text/javascript"></script>
	<link th:href="@{/layui/css/layui.css}" rel="stylesheet" />
</head>
<body>
<div class="layui-panel" style="padding: 8px;">
	<fieldset class="layui-elem-field layui-border-blue">
		<legend>搜索信息</legend>
		<form class="layui-form layui-form-pane" style="margin: 20px;">
			<div class="layui-form-item">
				<div class="layui-inline">
					<label class="layui-form-label">信息类型</label>
					<div class="layui-input-inline">
						<select class="layui-select" name="type">
							<option value="" title="请选择"></option>
							<option value="sms" >短信</option>
							<option value="email" >邮箱</option>
						</select>
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label">信息接收人</label>
					<div class="layui-input-inline">
						<input class="layui-input" type="text" name="acceptUser" autocomplete="off" />
					</div>
				</div>
				<div class="layui-inline">
					<div class="layui-input-inline">
						<a class="layui-btn layui-btn-primary" lay-submit="" lay-filter="searchBtn">
							<i class="layui-icon layui-icon-search"></i>
							搜索
						</a>
					</div>
				</div>
			</div>
		</form>
	</fieldset>
	<div>
		<table id="msgTable" lay-filter="msgTable"></table>
	</div>
</div>
<script id="tableBar" type="text/html">
	<a class="layui-btn layui-btn-normal layui-btn-md" lay-event="add">
		<i class="layui-icon layui-icon-add-1"></i>
		新增信息
	</a>

</script>
<script id="switchState" type="text/html">
	<input type="checkbox" name="state" value="{{d.state}}"
		   lay-skin="switch" lay-text="已发送|未发送" lay-filter="checkstate" {{d.state==0?"checked":""}} />
</script>
<script>

	var $;
	layui.use(['table','form','layer','jquery'],function () {
		var table = layui.table;
		$ = layui.jquery;
		//setHeight();
		table.render({
			elem:'#msgTable',
			height:'full-160',
			page: {
				theme:'#1e9fff'
			},
			url:'/system/smc/find',
			toolbar:'#tableBar',
			where:{
				status:0
			},
			cols:[
				[
					{type:'numbers',fixed:'left',align: 'center'},
					{type:'checkbox',fixed:'left',align: 'center'},
					{field:'type',title:'信息类型',width:150,align: 'center',
						templet:function (res) {
							if("sms" == res.type){return "短信"}
							return "邮箱";
						}
					},
					{field:'acceptUser',title:'信息接收人',width:100,align: 'center'},
					{field:'title',title:'信息标题',width:150,align: 'center'},
					{field:'content',title:'信息内容',minWidth:150},
					{field:'sendTime',title:'发送时间',width:100,align: 'center'},
					{field:'state',title:'发送状态',width:130,templet:'#switchState',align: 'center'},
				]
			]
		});


		table.on('toolbar(msgTable)',function(obj){
			var event = obj.event;
			if('add' == event){
				var b = false;
				top.layer.open({
					title:'新增信息发送',
					type:2,
					content:'/page/system/sendMessageAdd',
					area:['800px','600px'],
					btn:['确定提交','取消关闭'],
					btn1:function(i,o){
						b = true;
						o.find('iframe')[0].contentWindow.btnSubmit();
					},
					end:function () {
						if(b) layui.table.reload('msgTable');
					}
				})
			}
		});
	});

	//获取页面高度
	function setHeight(){
		var height = window.outerHeight-258;
		$('.layui-panel').css('height',height);
	}
</script>
</body>

</html>
